package com.ruoyi.web.controller.Tour;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.TourTravelNotes;
import com.ruoyi.system.service.ITourTravelNotesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 游记管理Controller
 *
 * @author once
 * @date 2020-10-02
 */
@RestController
@RequestMapping("/Tour/notes")
public class TourTravelNotesController extends BaseController
{
    @Autowired
    private ITourTravelNotesService tourTravelNotesService;

    /**
     * 查询游记管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:notes:list')")
    @GetMapping("/list")
    public TableDataInfo list(TourTravelNotes tourTravelNotes)
    {
        startPage();
        List<TourTravelNotes> list = tourTravelNotesService.selectTourTravelNotesList(tourTravelNotes);
        return getDataTable(list);
    }

    /**
     * 导出游记管理列表
     */
    @PreAuthorize("@ss.hasPermi('Tour:notes:export')")
    @Log(title = "游记管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TourTravelNotes tourTravelNotes)
    {
        List<TourTravelNotes> list = tourTravelNotesService.selectTourTravelNotesList(tourTravelNotes);
        ExcelUtil<TourTravelNotes> util = new ExcelUtil<TourTravelNotes>(TourTravelNotes.class);
        return util.exportExcel(list, "notes");
    }

    /**
     * 获取游记管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('Tour:notes:query')")
    @GetMapping(value = "/{travelNotesId}")
    public AjaxResult getInfo(@PathVariable("travelNotesId") Long travelNotesId)
    {
        return AjaxResult.success(tourTravelNotesService.selectTourTravelNotesById(travelNotesId));
    }

    /**
     * 新增游记管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:notes:add')")
    @Log(title = "游记管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourTravelNotes tourTravelNotes)
    {
        return toAjax(tourTravelNotesService.insertTourTravelNotes(tourTravelNotes));
    }

    /**
     * 修改游记管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:notes:edit')")
    @Log(title = "游记管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourTravelNotes tourTravelNotes)
    {
        return toAjax(tourTravelNotesService.updateTourTravelNotes(tourTravelNotes));
    }

    /**
     * 删除游记管理
     */
    @PreAuthorize("@ss.hasPermi('Tour:notes:remove')")
    @Log(title = "游记管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{travelNotesIds}")
    public AjaxResult remove(@PathVariable Long[] travelNotesIds)
    {
        return toAjax(tourTravelNotesService.deleteTourTravelNotesByIds(travelNotesIds));
    }
}
